<!DOCTYPE html>
<html xmlns:th="http://thymeleaf.org">
<head>
    <title></title>
    <link rel="stylesheet" th:href="@{/adminlte/bower_components/bootstrap/dist/css/bootstrap.min.css}">
    <!-- Font Awesome -->
    <link rel="stylesheet" th:href="@{/adminlte/bower_components/font-awesome/css/font-awesome.min.css}">
    <!-- Ionicons -->
    <link rel="stylesheet" th:href="@{/adminlte/bower_components/Ionicons/css/ionicons.min.css}">
    <!-- DataTables -->
    <link rel="stylesheet" th:href="@{/adminlte/bower_components/datatables.net-bs/css/dataTables.bootstrap.min.css}">
    <link rel="stylesheet" th:href="@{/adminlte/bower_components/bootstrap-datepicker/dist/css/bootstrap-datepicker.min.css}">
    <!-- Theme style -->
    <link rel="stylesheet" th:href="@{/adminlte/dist/css/AdminLTE.min.css}">
    <link rel="stylesheet" th:href="@{/adminlte/dist/css/skins/_all-skins.min.css}">
    <link rel="stylesheet" th:href="@{/adminlte/bower_components/fullcalendar/dist/fullcalendar.min.css}">
    <link rel="stylesheet" th:href="@{/adminlte/bower_components/fullcalendar/dist/fullcalendar.print.min.css}" media="print">
</head>
<body>
<div class="box box-info">
    <form class="form-horizontal" id="form2" th:action="@{/product/imageedit}" method="post" th:object="${product}" enctype="multipart/form-data">
        <div class="box-body">
            <input type="hidden" name="pId" th:field="*{pId}">
            <input type="file" name="file">
        </div>
        <button type="submit" class="btn btn-info pull-right" >上传头像</button>

</form>
<form class="form-horizontal" id="form1" th:action="@{/product/product_add}" method="post" th:object="${product}">
    <div class="box-body">
        <div class="form-group">
            <label class="col-sm-2 control-label">商品名称</label>
            <div class="col-sm-10">
                <input type="hidden" name="pId" th:field="*{pId}">
                <input type="text"  name="name" th:field="*{productName}" class="form-control" >
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label">商品价格</label>
            <div class="col-sm-10">
                <input type="text"  name="money" th:field="*{money}" class="form-control" >
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label">商品详情</label>
            <div class="col-sm-10">
                <textarea type="text" name="content"th:field="*{content}"></textarea>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label">商品库存</label>
            <div class="col-sm-10">
                <input type="text"  name="num" th:field="*{num}" class="form-control" >
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label">打折</label>
            <div class="col-sm-10">
                <input type="text"  name="dazhe" th:field="*{dazhe}" class="form-control" >
            </div>
        </div>
        <div class="form-group">
        <label class="col-sm-2 control-label">商品种类</label>
        <div class="col-sm-10">
            <input type="text"  name="dictionaryid" th:field="*{dictionaryid}" class="form-control" >
        </div>
    </div>
    </div>
    <!-- /.box-body -->
    <div class="box-footer">
        <button type="button" class="btn btn-default" id="btn_qx">取消</button>
        <button type="button" class="btn btn-info pull-right" id="btn_ok">确定</button>
    </div>
    <!-- /.box-footer -->
</form>
</div>
<script th:src="@{/adminlte/bower_components/jquery/dist/jquery.min.js}"></script>
<!-- Bootstrap 3.3.7 -->
<script th:src="@{/adminlte/bower_components/bootstrap/dist/js/bootstrap.min.js}"></script>
<!-- DataTables -->
<script th:src="@{/adminlte/bower_components/datatables.net/js/jquery.dataTables.min.js}"></script>
<script th:src="@{/adminlte/bower_components/datatables.net-bs/js/dataTables.bootstrap.min.js}"></script>
<!-- SlimScroll -->
<script th:src="@{/adminlte/bower_components/jquery-slimscroll/jquery.slimscroll.min.js}"></script>
<!-- FastClick -->
<script th:src="@{/adminlte/bower_components/fastclick/lib/fastclick.js}"></script>
<script th:src="@{/adminlte/dist/js/adminltejs/adminlte.min.js}"></script>
<script th:src="@{/adminlte/dist/js/demo.js}"></script>
<script th:src="@{/adminlte/bower_components/jquery-ui/jquery-ui.min.js}"></script>
<script th:src="@{/adminlte/bower_components/moment/moment.js}"></script>
<script th:src="@{/adminlte/bower_components/fullcalendar/dist/fullcalendar.min.js}"></script>
<script th:src="@{/adminlte/bower_components/layer/layer.js}"></script>
<script th:src="@{/adminlte/bower_components/bootstrap-datepicker/js/bootstrap-datepicker.js}"></script>
<script th:src="@{/adminlte/bower_components/bootstrap-datepicker/js/locales/bootstrap-datepicker.zh-CN.js}"></script>


<!-- AdminLTE App -->
<script th:src="@{/adminlte/dist/js/adminlte.min.js}"></script>
<!-- AdminLTE for demo purposes -->
<script th:src="@{/adminlte/dist/js/demo.js}"></script>
<script>
    $(function () {
        $("#hireDate").datepicker({
            format:"yyyy-mm-dd",
            language:"zh-CN"

        });
        $("#btn_qx").click(function () {
            var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
            parent.layer.close(index); //再执行关闭
        });

        $("#btn_ok").click(function () {
            $.ajax({
                type: "POST",
                url: "/product/product_add",
                data: $("#form1").serialize(),
                success: function(data){
                    if(data["result"]=="success")
                    {layer.msg("修改成功");
                        var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                        setTimeout(function (){
                            parent.layer.close(index)
                            parent.location.reload();
                        },1000);
                    }
                    else if(data["result"]=="fail"){
                        layer.msg("错误");
                    }

                  //  parent.layer.close(index); //再执行关闭
                },

            });

        });
    });

</script>

</body>
</html>
